package com.sds.smarthome.foundation;

import com.sds.smarthome.foundation.entity.AddOrUpdateYSRequest;
import com.sds.smarthome.foundation.entity.AppUibean;
import com.sds.smarthome.foundation.entity.AuthDevByQrcodeRequest;
import com.sds.smarthome.foundation.entity.BackupBean;
import com.sds.smarthome.foundation.entity.BindApartmentRequest;
import com.sds.smarthome.foundation.entity.BindEquesDoorbellReq;
import com.sds.smarthome.foundation.entity.BindOrAddShareDevReq;
import com.sds.smarthome.foundation.entity.BindOrAddShareDevResp;
import com.sds.smarthome.foundation.entity.BindSmartDevToCCuRequest;
import com.sds.smarthome.foundation.entity.BirthDayRequest;
import com.sds.smarthome.foundation.entity.EditPwdRequest;
import com.sds.smarthome.foundation.entity.ForgetPwdRequest;
import com.sds.smarthome.foundation.entity.GetAuthCodeResp;
import com.sds.smarthome.foundation.entity.GetQRCodeResponse;
import com.sds.smarthome.foundation.entity.LoginResponse;
import com.sds.smarthome.foundation.entity.LogoutRequest;
import com.sds.smarthome.foundation.entity.NickNameRequest;
import com.sds.smarthome.foundation.entity.OpenYsRequest;
import com.sds.smarthome.foundation.entity.OtherUserInfoResp;
import com.sds.smarthome.foundation.entity.RegistRequest;
import com.sds.smarthome.foundation.entity.SearchIsBindResp;
import com.sds.smarthome.foundation.entity.SendYsSmsCodeRequest;
import com.sds.smarthome.foundation.entity.SetYsNameRequest;
import com.sds.smarthome.foundation.entity.SetYsRoomRequest;
import com.sds.smarthome.foundation.entity.SexRequest;
import com.sds.smarthome.foundation.entity.SharedUsersResp;
import com.sds.smarthome.foundation.entity.SmartDevImage;
import com.sds.smarthome.foundation.entity.ThirdPartDevResponse;
import com.sds.smarthome.foundation.entity.UnbindAndTransferDevReq;
import com.sds.smarthome.foundation.entity.UpdateApartmentRequest;
import com.sds.smarthome.foundation.entity.UpdateCCuImgResp;
import com.sds.smarthome.foundation.entity.UpdateEquesReq;
import com.sds.smarthome.foundation.entity.UpdateProfileImgResp;
import com.sds.smarthome.foundation.entity.UpdatePushtokenRequest;
import com.sds.smarthome.foundation.entity.UserAuthorityBean;
import com.sds.smarthome.foundation.entity.UserGroupReq;
import com.sds.smarthome.foundation.entity.VerificationRequest;
import com.sds.smarthome.foundation.entity.YsAccesstokenResp;
import com.sds.smarthome.foundation.entity.YsBindResp;

import java.util.List;

import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Url;

/**
 * 智能家居云平台API,接口定义参考《智能家居云平台REST服务接口文档_》
 */
public interface SHCloudApi {


    String LOCAL_BASE_URL = "https://192.168.50.243:4431";

    String BASE_URL = "https://api.shomec.hijaytech.com:4431";

    @POST("/1.0/users/{user_id}/dev_push_token")
    Call<Void> updatePushToken(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                               @Path("user_id") String user_id, @Body UpdatePushtokenRequest request);

    @GET("/1.0/users/login")
    Call<LoginResponse> login(@Header("Authorization") String credential);

    @POST("/1.0/users/{user_id}/actions")
    Call<Void> logout(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                      @Path("user_id") String user_id, @Body LogoutRequest request);

    @POST("/1.0/phone_verification_code")
    Call<Void> getVerificationCode(@Body VerificationRequest request);

    @POST("/1.0/users")
    Call<LoginResponse> regist(@Body RegistRequest request);

    @POST("/1.0/users/actions")
    Call<Void> resetPwd(@Body ForgetPwdRequest request);

    @PUT("/1.0/users/{user_id}/app_ui")
    Call<Void> updateAppUI(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                           @Path("user_id") String user_id, @Body AppUibean request);

    @POST("/1.0/users/{user_id}/actions")
    Call<Void> changePwd(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                         @Path("user_id") String user_id, @Body EditPwdRequest request);

    @GET("/1.0/users/current_user")
    Call<LoginResponse> userInfo(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token);

    @POST("/1.0/users/{user_id}/nick_name")
    Call<Void> updateNickname(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                              @Path("user_id") String user_id, @Body NickNameRequest request);

    @PUT("/1.0/users/{user_id}/sex")
    Call<Void> updateSex(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                         @Path("user_id") String user_id, @Body SexRequest request);

    @PUT("/1.0/users/{user_id}/birthday")
    Call<Void> updateBirthDay(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                              @Path("user_id") String user_id, @Body BirthDayRequest request);

    @Multipart
    @POST("/1.0/users/{user_id}/profile_image")
    Call<UpdateProfileImgResp> uploadProfileImage(@Header("sds_user_id") String sds_user_id,
                                                  @Header("sds_user_token") String sds_user_token,
                                                  @Path("user_id") String user_id, @Part MultipartBody.Part file);

    @Multipart
    @POST("/1.0/users/{user_id}/smart_devs/{dev_id}/app_images")
    Call<UpdateCCuImgResp> uploadCCuImage(@Header("sds_user_id") String sds_user_id,
                                          @Header("sds_user_token") String sds_user_token,
                                          @Path("user_id") String user_id, @Path("dev_id") String dev_id,
                                          @Part MultipartBody.Part file, @Part MultipartBody.Part describ);

    @POST("/1.0/users/{user_id}/smart_devs/{dev_id}/nick_name")
    Call<Void> updateCCuNickname(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                                 @Path("user_id") String user_id, @Path("dev_id") String dev_id, @Body NickNameRequest request);

    @GET("/1.0/users/{user_id}/smart_devs/{dev_id}/app_images")
    Call<List<SmartDevImage>> smartDevImages(@Header("sds_user_id") String sds_user_id,
                                             @Header("sds_user_token") String sds_user_token,
                                             @Path("user_id") String user_id, @Path("dev_id") String dev_id);

    @GET("/1.0/users/{user_id}/third_part_devices")
    Call<ThirdPartDevResponse> userThirdDevice(@Header("sds_user_id") String sds_user_id,
                                               @Header("sds_user_token") String sds_user_token,
                                               @Path("user_id") String user_id);

    @POST("/1.0/users/{user_id}/smart_devs")
    Call<BindOrAddShareDevResp> bindOrAddDevice(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                                                @Path("user_id") String user_id, @Body BindOrAddShareDevReq request);

    @POST("/1.0/users/{user_id}/smart_devs/{dev_id}/unbind_and_transfer_administrator")
    Call<Void> unbindAndTransferDevice(@Header("sds_user_id") String sds_user_id,
                                       @Header("sds_user_token") String sds_user_token,
                                       @Path("user_id") String user_id,
                                       @Path("dev_id") String devId, @Body UnbindAndTransferDevReq request);

    @DELETE("/1.0/users/{user_id}/smart_devs/{dev_id}")
    Call<Void> unbindOrDelDevice(@Header("sds_user_id") String sds_user_id,
                                 @Header("sds_user_token") String sds_user_token,
                                 @Path("user_id") String user_id,
                                 @Path("dev_id") String devId);

    @GET("/1.0/users/{user_id}/smart_devs/{dev_id}/shared_users")
    Call<SharedUsersResp> getSharedUsers(@Header("sds_user_id") String sds_user_id,
                                         @Header("sds_user_token") String sds_user_token,
                                         @Path("user_id") String user_id,
                                         @Path("dev_id") String devId);

    @DELETE("/1.0/users/{user_id}/smart_devs/{dev_id}/shared_users/{shared_user_id}")
    Call<Void> deleteSharedUser(@Header("sds_user_id") String sds_user_id,
                                @Header("sds_user_token") String sds_user_token,
                                @Path("user_id") String user_id,
                                @Path("dev_id") String devId,
                                @Path("shared_user_id") String shared_user_id);

    @PUT("/1.0/users/{user_id}/smart_devs/{dev_id}/shared_users/{shared_user_id}/groups")
    Call<Void> updateUserGroup(@Header("sds_user_id") String sds_user_id,
                               @Header("sds_user_token") String sds_user_token,
                               @Path("user_id") String user_id,
                               @Path("dev_id") String devId,
                               @Path("shared_user_id") String shared_user_id,
                               @Body List<UserGroupReq> userGroupReq);

    @PUT("/1.0/users/{user_id}/smart_devs/{dev_id}/shared_users/{shared_user_id}/nick_name")
    Call<Void> updateShredUserNickName(@Header("sds_user_id") String sds_user_id,
                                       @Header("sds_user_token") String sds_user_token,
                                       @Path("user_id") String user_id,
                                       @Path("dev_id") String devId,
                                       @Path("shared_user_id") String shared_user_id,
                                       @Body NickNameRequest userGroupReq);

    @PUT("/1.0/users/{user_id}/smart_devs/{dev_id}/shared_users/{shared_user_id}/authority")
    Call<Void> updateShredUserAuthority(@Header("sds_user_id") String sds_user_id,
                                        @Header("sds_user_token") String sds_user_token,
                                        @Path("user_id") String user_id,
                                        @Path("dev_id") String devId,
                                        @Path("shared_user_id") String shared_user_id,
                                        @Body UserAuthorityBean userGroupReq);

    @GET("1.0/users/{user_id}/base_info")
    Call<OtherUserInfoResp> getOtherUserInfo(@Header("sds_user_id") String sds_user_id,
                                             @Header("sds_user_token") String sds_user_token,
                                             @Path("user_id") String user_id);

    @GET("/1.0/ys_bind_state/{phone}")
    Call<YsBindResp> checkYsBindState(@Header("sds_user_id") String sds_user_id,
                                      @Header("sds_user_token") String sds_user_token,
                                      @Path("phone") String phone);

    @POST("/2.0/users/{userId}/ys_device/user_sms_code")
    Call<Void> sendYsCode(@Header("sds_user_id") String sds_user_id,
                          @Header("sds_user_token") String sds_user_token,
                          @Path("userId") String userId,
                          @Body SendYsSmsCodeRequest request);

    @POST("/2.0/users/{userId}/ys_device/user_ys_cloud_service")
    Call<Void> openYinshiService(@Header("sds_user_id") String sds_user_id,
                                 @Header("sds_user_token") String sds_user_token,
                                 @Path("userId") String userId,
                                 @Body OpenYsRequest request);

    @GET("/1.0/users/{user_id}/access_token")
    Call<YsAccesstokenResp> getAccessToken(@Header("sds_user_id") String sds_user_id,
                                           @Header("sds_user_token") String sds_user_token,
                                           @Path("user_id") String userId);

    @GET("/2.0/users/{user_id}/ys_device/{dev_sn}")
    Call<ThirdPartDevResponse.YSInfo> getYsInfo(@Header("sds_user_id") String sds_user_id,
                                                @Header("sds_user_token") String sds_user_token,
                                                @Path("user_id") String userId, @Path("dev_sn") String dev_sn);

    @POST("/2.0/users/{user_id}/ys_device")
    Call<Void> addOrUpdateYsInfo(@Header("sds_user_id") String sds_user_id,
                                 @Header("sds_user_token") String sds_user_token,
                                 @Path("user_id") String userId, @Body AddOrUpdateYSRequest request);

    @PUT("/2.0/users/{user_id}/ys_device/{serialId}/need_rebind")
    Call<Void> updateYsRebind(@Header("sds_user_id") String sds_user_id,
                              @Header("sds_user_token") String sds_user_token,
                              @Path("user_id") String userId, @Path("serialId") String serialId);

    @POST("/1.0/users/{user_id}/ys_device/name")
    Call<Void> setYsCamName(@Header("sds_user_id") String sds_user_id,
                            @Header("sds_user_token") String sds_user_token,
                            @Path("user_id") String userId, @Body SetYsNameRequest request);

    @POST("/1.0/users/{user_id}/ys_device/room")
    Call<Void> setYsCamRoom(@Header("sds_user_id") String sds_user_id,
                            @Header("sds_user_token") String sds_user_token,
                            @Path("user_id") String userId, @Body SetYsRoomRequest request);

    @DELETE("/1.0/users/{user_id}/ys_device/{serial_id}")
    Call<Void> unbindYsCam(@Header("sds_user_id") String sds_user_id,
                           @Header("sds_user_token") String sds_user_token,
                           @Path("user_id") String userId, @Path("serial_id") String serialId);

    @GET("/1.0/users/{user_id}/smart_devs/{dev_id}/share_qr_code")
    Call<GetQRCodeResponse> getDevQrcode(@Header("sds_user_id") String sds_user_id,
                                         @Header("sds_user_token") String sds_user_token,
                                         @Path("user_id") String userId, @Path("dev_id") String devId);

    @GET("/1.0/yk_devices/{serial_id}/bind_status")
    Call<SearchIsBindResp> searchIsBind(@Header("sds_user_id") String sds_user_id,
                                        @Header("sds_user_token") String sds_user_token,
                                        @Path("serial_id") String serialId);

    @POST("/1.0/yk_devices")
    Call<Void> bindEquesDoorbell(@Header("sds_user_id") String sds_user_id,
                                 @Header("sds_user_token") String sds_user_token,
                                 @Body BindEquesDoorbellReq request);

    @PUT("/1.0/yk_devices/{serial_id}")
    Call<Void> editEquesDoorbell(@Header("sds_user_id") String sds_user_id,
                                 @Header("sds_user_token") String sds_user_token,
                                 @Path("serial_id") String serialId,
                                 @Body UpdateEquesReq request);

    @DELETE("/1.0/yk_devices/{serial_id}")
    Call<Void> deleteEquesDoorbell(@Header("sds_user_id") String sds_user_id,
                                   @Header("sds_user_token") String sds_user_token,
                                   @Path("serial_id") String serialId);

    @POST("/1.0/wj_devices")
    Call<ThirdPartDevResponse.WJInfo> bindWeijuDevice(@Header("sds_user_id") String sds_user_id,
                                                      @Header("sds_user_token") String sds_user_token,
                                                      @Body BindApartmentRequest request);

    @DELETE("/1.0/wj_devices/{wj_dev_id}")
    Call<Void> deleteWeijuDevice(@Header("sds_user_id") String sds_user_id,
                                 @Header("sds_user_token") String sds_user_token,
                                 @Path("wj_dev_id") String wjDevId);

    @PUT("/1.0/wj_devices/{wj_dev_id}")
    Call<ThirdPartDevResponse.WJInfo> editWeijuDevice(@Header("sds_user_id") String sds_user_id,
                                                      @Header("sds_user_token") String sds_user_token,
                                                      @Path("wj_dev_id") String wjDevId,
                                                      @Body UpdateApartmentRequest request);

    @PUT("/1.0/users/{user_id}/smart_devs/{dev_id}/ccu")
    Call<Void> bindSmartDevToCcu(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                                 @Path("user_id") String user_id, @Path("dev_id") String dev_id, @Body BindSmartDevToCCuRequest request);

    @DELETE("/1.0/users/{user_id}/smart_devs/{dev_id}/ccu")
    Call<Void> unBindSmartDevToCcu(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                                   @Path("user_id") String user_id, @Path("dev_id") String dev_id);

    @POST("/1.0/users/{user_id}/smart_devs/{dev_id}/dev_auth")
    Call<Void> authDevByQrcode(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                               @Path("user_id") String user_id, @Path("dev_id") String dev_id, @Body AuthDevByQrcodeRequest request);


    @POST("/1.0/users/{user_id}/temp_auth_token")
    Call<GetAuthCodeResp> getUserTempAuthcode(@Header("sds_user_id") String sds_user_id, @Header("sds_user_token") String sds_user_token,
                                              @Path("user_id") String user_id);


    @GET("/1.0/users/{user_id}/backup_ccu")
    Call<List<BackupBean>> queryBackupBeans(@Header("sds_user_id") String sds_user_id,
                                       @Header("sds_user_token") String sds_user_token,
                                       @Path("user_id") String user_id);

    @GET
    Call<ResponseBody> downloadBackup(@Url String downloadUrl);
}
